<template>

<tbody>
  <tr>
    <td><input type="checkbox" /> <span></span></td>
    <td>{{item.name}}</td>
    <td>{{item.price}}</td>
    <td>
      <button @click="onBtnClick(-1)">-</button>
      {{item.num}}
      <button @click="onBtnClick(1)">+</button>
    </td>
    <td>{{item.price*item.num}}</td>
    <td><button>删除</button></td>
  </tr>
</tbody>

</template>

<script>
export default {
  props: {
    item: Object
  },
  methods: {
    onBtnClick (step) {
      const newNum = this.item.num + step
      // console.log(this.item.id)
      if (newNum < 1) return
      this.$store.dispatch('goodli/updateNum', {
        id: this.item.id,
        num: newNum
      })
    }
  }
}
</script>

<style>

</style>
